#include <QtGui>
#include <QtCore/QTextCodec>
#include <QTranslator>
#include "gv_setuphomedialog.h"
#include "gv_setupchangepwddiaglog.h"
#include "gv_setuplanguagedialog.h"
#include "gv_setuptimedialog.h"
#include "gv_securityhomedialog.h"
#include "gv_securitychangepwddiaglog.h"
#include "gv_home.h"
#include "gv_setting.h"

extern GV_Setting *gvsetting;
extern QDialog  *dialog;
GV_SecurityHomeDialog::GV_SecurityHomeDialog(QWidget *parent)
       : QDialog(parent)
{
    setupUi(this);

    QTranslator translator;
    translator.load(gvsetting->GV_GetLanguage(),".");
    qApp->installTranslator(&translator);
    reloadtext();

    TimeHintsLabel->setText((QDateTime::currentDateTime().toString("hh:mm:ss")));
    DateHintsLabel->setText((QDateTime::currentDateTime().toString("yyyy-MM-dd")));
    timer = new QTimer;
    connect(timer,SIGNAL(timeout()),this,SLOT(GV_chTime()));
    connect(BackButton,SIGNAL(clicked()),this,SLOT(home()));
    connect(CancelButton,SIGNAL(clicked()),this,SLOT(home()));

    connect(Level1SetButton,SIGNAL(clicked()),this,SLOT(setlevel1()));
    connect(Level2SetButton,SIGNAL(clicked()),this,SLOT(setlevel2()));
    connect(Level3SetButton,SIGNAL(clicked()),this,SLOT(setlevel3()));
    //connect(TimeanddateButton,SIGNAL(clicked()),this,SLOT(timeanddate()));
    //connect(LanguageselectionButton,SIGNAL(clicked()),this,SLOT(changelanguage()));

    for(int i = 0; i< 3; i++)
    {
        buttonstatus[i]=false;
    }
    timer->start(1000);
}
void GV_SecurityHomeDialog::reloadtext()
{
    //NameHintsLabel->setText(tr("Zones"));
}
void GV_SecurityHomeDialog::GV_chTime()
{
    TimeHintsLabel->setText((QDateTime::currentDateTime().toString("hh:mm:ss")));
    DateHintsLabel->setText((QDateTime::currentDateTime().toString("yyyy-MM-dd")));
}

void GV_SecurityHomeDialog::home()
{
    QDialog *dialog1 = new gv_home;
    dialog1->show();
    delete dialog;
    dialog = dialog1;
}

void GV_SecurityHomeDialog::setlevel1()
{
    if(0)
    {
        QDialog *dialog1 = new GV_SecurityChangePWDDialog;
        dialog1->show();
        delete dialog;
        dialog = dialog1;
    }
    else
    {
        if(buttonstatus[0]==false)
        {
            buttonstatus[0]=true;
            Level1SetButton->setStyleSheet("border-image: url(:/images/HomeBg.jpg);");
        }
        else if(buttonstatus[0]==true)
        {
            buttonstatus[0]=false;
            Level1SetButton->setStyleSheet("");
        }
    }
}

void GV_SecurityHomeDialog::setlevel2()
{
    if(buttonstatus[1]==false)
    {
        buttonstatus[1]=true;
        Level2SetButton->setStyleSheet("border-image: url(:/images/HomeBg.jpg);");
    }
    else if(buttonstatus[1]==true)
    {
        buttonstatus[1]=false;
        Level2SetButton->setStyleSheet("");
    }

}
void GV_SecurityHomeDialog::setlevel3()
{
    if(buttonstatus[2]==false)
    {
        buttonstatus[2]=true;
        Level3SetButton->setStyleSheet("border-image: url(:/images/HomeBg.jpg);");
    }
    else if(buttonstatus[2]==true)
    {
        buttonstatus[2]=false;
        Level3SetButton->setStyleSheet("");
    }

}



